package com.ylbh.modules.sign.controller;

import com.ylbh.common.exception.NormalException;
import com.ylbh.common.pojo.sign.dto.SignUserLogDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.sign.entity.ShoppingSigninIssuelog;
import com.ylbh.modules.sign.service.ShoppingSigninUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @author; wjc
 * @date: 2019/12/17
 */
@RestController
@RequestMapping("userlog")
public class ShoppingSigninUserlogController {

    @Autowired
    private ShoppingSigninUserService shoppingSigninUserService;

    @ApiOperation("获取抽奖记录例表")
    @RequestMapping("queryUserLogList")
    public CommonResult<PageUtils> queryUserLogList(SignUserLogDTO signUserLogDTO) {
        PageUtils userLogList =  shoppingSigninUserService.queryUserLogList(signUserLogDTO);
        return Ref.ok(userLogList);
    }
    @ApiOperation("发放奖励记录添加")
    @RequestMapping("addIssueLogInfo")
    public CommonResult addIssueLogInfo(@RequestBody ShoppingSigninIssuelog shoppingSigninIssuelog ) {
        shoppingSigninUserService.addIssueLogInfo(shoppingSigninIssuelog);
        return Ref.ok();
    }

    @ApiOperation("导出抽奖记录记录")
    @RequestMapping("userlogExcel")
    public CommonResult<Void> userlogExcel(HttpServletRequest request, HttpServletResponse response) throws NormalException {
        shoppingSigninUserService.userlogExcel(request, response);
        return Ref.ok();
    }
}
